From bb4e0350373c597a02afaf89609b864dd3bbe32e Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Tue, 27 Apr 2021 15:57:11 -0500 Subject: [PATCH] Use SetupError name from pgwui_core instead of just Error --- src/pgwui_common/exceptions.py | 24 ++++++++++++------------ tests/test_exceptions.py | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/pgwui_common/exceptions.py b/src/pgwui_common/exceptions.py index ab71e8a..1015ced 100644 --- a/src/pgwui_common/exceptions.py +++ b/src/pgwui_common/exceptions.py @@ -26,7 +26,7 @@ from pgwui_core import exceptions as core_ex from pgwui_core.exceptions import ( # noqa: F401 PGWUIError, - UploadError as Error, + UploadError, SetupError, ) from . import constants @@ -45,7 +45,7 @@ class MenuPageInRoutes(Info): 'and the pgwui.menu_page setting used instead') -class BadHMACError(Error): +class BadHMACError(SetupError): pass @@ -61,22 +61,22 @@ class HMACLengthError(BadHMACError): .format(constants.HMAC_LEN)) -class UnknownSettingKeyError(Error): +class UnknownSettingKeyError(SetupError): def __init__(self, key): super().__init__('Unknown PGWUI setting: {}'.format(key)) -class MissingSettingError(Error): +class MissingSettingError(SetupError): def __init__(self, key): super().__init__('Missing PGWUI setting: {}'.format(key)) -class BadPageTypeError(Error): +class BadPageTypeError(SetupError): def __init__(self, key, val): super().__init__(f'Bad {key} setting ({val})') -class BadPageSourceError(Error): +class BadPageSourceError(SetupError): def __init__(self, msg): super().__init__(msg) @@ -117,7 +117,7 @@ class BadAssetSourceError(BadPageSourceError): 'does not look like a Pyramid asset specification') -class NotBooleanSettingError(Error): +class NotBooleanSettingError(SetupError): def __init__(self, key, value): super().__init__( f'Bad value ({value}) for the {key} setting', @@ -125,7 +125,7 @@ class NotBooleanSettingError(Error): .format(key)) -class NotBooleanChoiceSettingError(Error): +class NotBooleanChoiceSettingError(SetupError): def __init__(self, key, value): super().__init__( f'Bad value ({value}) for the {key} setting', @@ -133,21 +133,21 @@ class NotBooleanChoiceSettingError(Error): '"yes-always", "choice-yes", "choice-no", "no-never"')) -class BadAssetOverrideError(Error): +class BadAssetOverrideError(SetupError): def __init__(self, asset, new_asset, exp): super().__init__( f'The asset ({asset}) cannot be overridden with ({new_asset}):' f' {exp}') -class BadSettingError(Error): +class BadSettingError(SetupError): def __init__(self, exp): super().__init__( f'Bad settings caused an error: {exp}' '\nHint: Overriding non-existant assets can cause this problem') -class BadPathError(Error): +class BadPathError(SetupError): pass @@ -167,7 +167,7 @@ class BadAssetError(BadPathError): 'an asset that does not exist') -class ViewError(Error): +class ViewError(SetupError): pass diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 43ad7b8..48b8ac4 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -33,7 +33,7 @@ def test_badsettingerror(): # when exiting the configuration context raises a configuration # execution error. assert isinstance(common_ex.BadSettingError('foo'), - common_ex.Error) + common_ex.SetupError) # Functional tests @@ -42,18 +42,18 @@ def test_badsettingerror(): def test_unknownsettingkeyerror(): '''Takes an argument''' assert isinstance(common_ex.UnknownSettingKeyError('key'), - common_ex.Error) + common_ex.SetupError) @pytest.mark.integrationtest def test_missingsettingerror(): '''Takes an argument''' assert isinstance(common_ex.MissingSettingError('key'), - common_ex.Error) + common_ex.SetupError) @pytest.mark.integrationtest def test_notbooleansettingerror(): '''Takes two arguments''' assert isinstance(common_ex.NotBooleanSettingError('key', 'val'), - common_ex.Error) + common_ex.SetupError) -- 2.34.1